package nl.hanze.designpatterns.mvc.view;

import java.awt.GridLayout;

import nl.hanze.designpatterns.domain.TroubleTicket;
import nl.hanze.designpatterns.mvc.controller.TroubleTicketController;
import nl.hanze.designpatterns.mvc.model.TroubleTicketModel;

public class TroubleTicketView extends View<TroubleTicketController, TroubleTicketModel>{
	
	private TroubleTicketShowAllView allTickets;
	private TroubleTicketSelectedView selected;
	
	public TroubleTicketView(TroubleTicketController controller, TroubleTicketModel model) {
		super(controller, model);
		this.allTickets = new TroubleTicketShowAllView(controller, model);
		this.selected = new TroubleTicketSelectedView(controller, model);
		
		GridLayout layout = new GridLayout(2,1);
		this.setLayout(layout);
		
		this.add(selected);
		this.add(allTickets);
		
		this.setVisible(true);
	}
	
	public void updateSelectedView(TroubleTicket ticket){
		this.selected.updateSelectedView(ticket);
	}
	
	public void showTicketsOfCaller(Object[][] tableData){
		this.allTickets.showTicketsOfCaller(tableData);
	}
	
	public void showAllTickets(){
		this.allTickets.tableShowAllTroubleTicketsData();
	}
	
	@Override
	public void notifyChange() {
		System.out.println("[INFO] Notify TroubleTicketView");
		this.allTickets.notifyChange();
	}

}
